package com.kolon.business.main.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.kolon.business.main.dao.MainDao;
import com.kolon.framework.interfaces.SimpleController;
import com.kolon.framework.util.ComUtil;

@Controller("com.kolon.business.main.controller.SearchController")
public class SearchController implements SimpleController {
	
	@Resource(name="MainDaoImpl")
	private MainDao mainDao;
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@RequestMapping(value="/business/main/search.do")
	public ModelAndView controller(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		// 파라미터
		Map map = new HashMap();
		String schTxt = ComUtil.nullChk(request.getParameter("schTxt"));
		map.put("schTxt", schTxt);
		// 리턴
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.addObject("servList", mainDao.getSchList(map));
		modelAndView.addObject("schTxt", schTxt);
		modelAndView.addObject("schTxtUTF8", ComUtil.getEncode(schTxt, "UTF-8"));

		return modelAndView;
	}

}
